package meihua.stopcarapp.model;

import meihua.mylibrary.basebean.ResultModel;
import meihua.mylibrary.baserx.RxSchedulers;
import meihua.stopcarapp.api.Api;
import meihua.stopcarapp.api.URLType;
import meihua.stopcarapp.bean.UserEntity;
import meihua.stopcarapp.presenter.contract.UserInfoContract;
import rx.Observable;
import rx.functions.Func1;

/**
 * Created by 小杜 on 2017/5/10.
 */

public class UserInfoModel implements UserInfoContract.Model {

    @Override
    public Observable<String> getUserNickName(String user_phone, String user_id, String user_nickname) {
        return Api.getDefault( URLType.STOPCAR_URL)
                .getUserNickName(user_phone, user_id,user_nickname)
                .map(new Func1<ResultModel<String>, String>() {
                    @Override
                    public String call(ResultModel<String> listResultModel) {
                        String str = listResultModel.getData();
                        return str;
                    }
                })
                .compose( RxSchedulers.<String>io_main());
    }

    @Override
    public Observable<UserEntity> getUserSex(String user_phone, String user_sex) {
        return Api.getDefault( URLType.STOPCAR_URL)
                .getUserSex(user_phone, user_sex)
                .map(new Func1<ResultModel<UserEntity>, UserEntity>() {
                    @Override
                    public UserEntity call(ResultModel<UserEntity> listResultModel) {
                        return listResultModel.getData();
                    }
                })
                .compose( RxSchedulers.<UserEntity>io_main());
    }

    @Override
    public Observable<String> getUserPhone(String user_phone, String user_id) {
        return null;
    }

    @Override
    public Observable<String> getUserCard(String user_id, String user_phone, String user_idcard, String user_name) {
        return null;
    }

    @Override
    public Observable<String> getUserPlateNumber(String user_phone, String user_id, String user_carid) {
        return null;
    }

    @Override
    public Observable<String> getUserQuit(String user_phone, String user_state) {
        return null;
    }
}
